<#include "/common/head.ftl">
<@head>

<div class="container">
<form action="/api/user/login" method="post">
  <div class="form-group">
    <label for="exampleInputEmail1">用户名</label>
    <input type="text" class="form-control" id="exampleInputEmail1" placeholder="用户名"  name="userName" value="${account!}">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1">密码</label>
    <input type="password" class="form-control" id="exampleInputPassword1" placeholder="密码"  name="passwd" value="${account!}">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1">校验码</label>
    <input type="text" class="form-control" id="captcha1" placeholder="密码"  name="captcha"  autocomplete="off">
    <img src="/user/captcha" id="captcha2"/> (不区分大小写)
  </div>
 
  <button type="submit" class="btn btn-default">登陆</button>
</form>

 
</div>

    
<@js>
//-------

$("#captcha2").click(function(){
    $(this).attr("src","/user/captcha?"+Math.random());
    $("#captcha1").val("");
});

$("form").submit(function(e){
    e.preventDefault();
	$.post("/api/user/login", $("form").serialize(),function(data){
          console.log(data); //  2pm
         if(data.status==200){
			window.location.href='/';
         }else{
            alert(data.message);
            $("#captcha2").click();
         }
    }, "json");
    
});

          
          

</@js>

</@head>